import ajax from '@/utils/ajax'
let _this_;
const getData = () => _this_.curData || _this_.curData;
let permCheck = (rule, value, callback) => {
    _this_.$ajax.get(_this_.$api.system.perm.check,{code:getData().code,id:getData().id}).then(result => {
        if(result.bean>0) {
            callback("权限编码已存在");
        } else {
            callback();
        }
    }).catch(error => {
        callback("获取权限编码异常");
    });
}
export default function (context) {
    _this_ = context;
    return {
        code: [
            {required: true, message: '请输入标识', trigger: 'blur'},
            {min: 3, max: 25, message: '长度在 3 到 55 个字符', trigger: 'blur'},
            {pattern: /^[a-zA-Z0-9:]+$/, message: '标识格式不正确', trigger: 'blur'},
            {validator: permCheck, trigger: 'blur'},
        ],
        name: [
            {required: true, message: '请输入名称', trigger: 'blur'},
            {min: 1, max: 25, message: '长度在 1 到 20 个字符', trigger: 'blur'},
        ],
        parentId: [
            {required: true, message: '请输入菜单', trigger: 'blur'},
        ],
        sort: [
            {required: true, message: '请输入排序', trigger: 'blue'},
            {pattern: /^[0-9]{1,3}$/, message: '必须为数字范围0到999', trigger: 'blue'},
        ]
    }
}
